#include "widget.h"


namespace infinity {

Widget::Widget()
:m_zOrder(LAYER_BACK)
{
	m_position = dw::maths::Vector2f(0.0f,0.0f);
}

Widget::~Widget()
{

}

/*virtual*/ dw::uint32 Widget::collectGeometry(/*VertexBuffer* vb, IndexBuffer *ib*/std::vector<UiVertex>* vb, std::vector< dw::uint16 >* ib, const dw::maths::Vector2f& posOffset)
{
	dw::maths::Vector2f newPos = m_position + posOffset;

	dw::uint32 childrenTriangles = 0;

	for (dw::uint32 index = 0; index < m_children.size(); ++index)
	{

		childrenTriangles += m_children[index]->collectGeometry(vb, ib, newPos);
	}

	return childrenTriangles;
}

void Widget::addChild(Widget *widg)
{
	m_children.push_back(widg);
}

void Widget::deleteChildren()
{
	for (dw::uint32 index = 0; index < m_children.size(); ++index)
	{
		m_children[index]->deleteChildren();
	}
	m_children.clear();
}

}